<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      list-style: none;
      text-decoration: none;
    }
    .box{
      width:920px;
      border:1px solid red;
      margin:40px auto;
    }
    .title li{
      float: left;
      line-height: 40px;
    }
    a{
      display: block;
      text-align: center;
      width: 184px;
      background: #ccc;
      color:black;
    }
    .active{
      background: #fff !important;
      color:red !important;
      border-top:3px solid red;
    }
  
  </style>
</head>
<body>
  <div class="box">
    <div class="title">
      <ul>
        <li><a href="#" class="active">疯狂购物</a></li>
        <li><a href="#">热卖推荐</a></li>
        <li><a href="#">猜你喜欢</a></li>
        <li><a href="#">新品上架</a></li>
        <li><a href="#">整箱特卖</a></li>
      </ul>
    </div>
    <div>
      <div class="public o1" style="display:block;"><img src="img/01.bmp" alt=""></div>
      <div class="public o2" style="display:none;"><img src="img/02.bmp" alt=""></div>
      <div class="public o3" style="display:none;"><img src="img/03.bmp" alt=""></div>
      <div class="public o4" style="display:none;"><img src="img/04.bmp" alt=""></div>
      <div class="public o5" style="display:none;"><img src="img/05.bmp" alt=""></div>
    </div>
  </div>
  <script>
    var a_btns = document.querySelectorAll('a');
    var public = document.querySelectorAll('.public');

    for(var i = 0; i < a_btns.length; i++){
      a_btns[i].index = 'o'+Number(i+1);
      a_btns[i].onmouseenter = function(){
        document.querySelector('.active').classList.remove('active')
        this.classList.add('active');
        for(var j = 0; j < public.length; j++){
          public[j].style.display = 'none';
        }
      
        document.querySelector('.'+(this.index)).style.display = 'block';
      }
    }
  </script>
</body>
</html>